import React from 'react';
import { Navigate } from 'react-router-dom';
import type { RouteObject } from 'react-router-dom';
import AuthGuard from '@/components/AuthGuard';

const Login = React.lazy(() => import('../pages/Login/Index'));
const Home = React.lazy(() => import('../layout/Index'));
const Dashboard = React.lazy(() => import('../pages/Dashboard'));
const UserManage = React.lazy(() => import('../pages/UserManage'));
const OrderList = React.lazy(() => import('../pages/Order/Index'));
const OrderReview = React.lazy(() => import('../pages/Order/Review'));
const Settings = React.lazy(() => import('../pages/Settings'));
const NotFound = React.lazy(() => import('../pages/404/Index'));
const ArticleList = React.lazy(() => import('../pages/AiticleListMs/Index'));

const routes: RouteObject[] = [
  {
    path: '/',
    element: <Navigate to="dashboard" />
  },
  {
    path: '/login',
    element: <Login />
  },
  {
    path: '/',
    element: <AuthGuard><Home /></AuthGuard>,
    children: [
      {
        path: 'dashboard',
        element: <Dashboard />
      },
      {
        path: 'user',
        element: <UserManage />
      },
      {
        path: 'settings',
        element: <Settings/>
      },
      {
        path: 'yuer-article-list',
        element: <ArticleList />
      },
      {
        path: 'order-list',
        element: <OrderList />
      },
      {
        path: 'order-review',
        element: <OrderReview />
      }
    ]
  },
  {
    path: '*',
    element: <NotFound />
  }
];

export default routes; 